﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// 生产车间
    /// </summary>
    public partial class Worksho : BusEntity
    {
        /// <summary>
        /// 车间编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 车间名称
        /// </summary>
        public string Name { get; set; }
    }

    public partial class Worksho : BusEntity
    {
        /// <summary>
        /// 生产区域实体列表
        /// </summary>
        public List<WorkshoArea> Areas { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class WorkshoTypeConfig : BusEntityTypeConfig<Worksho>, IEntityTypeConfiguration<Worksho>
    {
        public override void Configure(EntityTypeBuilder<Worksho> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("生产车间");
            builder.Property(p => p.Code).HasComment("车间编码");
            builder.Property(p => p.Name).HasComment("车间名称");
            #endregion

            #region 种子数据
            builder.HasData(new Worksho() { Id = "C9", Name = "搅拌桶自动化生产线", Code = "C9", CreateUserId = "1", ModifyUserId = "1" });
            #endregion
        }
    }
}
